package com.lxmes.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.pm.domain.AZsShare;
import com.lxmes.pm.service.IAZsShareService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 知识共享Controller
 * 
 * @author zhangzhiyu
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/pm/zsShare")
public class AZsShareController extends BaseController
{
    @Autowired
    private IAZsShareService aZsShareService;

    /**
     * 查询知识共享列表
     */
    @PreAuthorize("@ss.hasPermi('pm:zsShare:list')")
    @GetMapping("/list")
    public TableDataInfo list(AZsShare aZsShare)
    {
        startPage();
        List<AZsShare> list = aZsShareService.selectAZsShareList(aZsShare);
        return getDataTable(list);
    }

    /**
     * 导出知识共享列表
     */
    @PreAuthorize("@ss.hasPermi('pm:zsShare:export')")
    @Log(title = "知识共享", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AZsShare aZsShare)
    {
        List<AZsShare> list = aZsShareService.selectAZsShareList(aZsShare);
        ExcelUtil<AZsShare> util = new ExcelUtil<AZsShare>(AZsShare.class);
        util.exportExcel(response, list, "知识共享数据");
    }

    /**
     * 获取知识共享详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:zsShare:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aZsShareService.selectAZsShareById(id));
    }

    /**
     * 新增知识共享
     */
    @PreAuthorize("@ss.hasPermi('pm:zsShare:add')")
    @Log(title = "知识共享", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AZsShare aZsShare)
    {
        return toAjax(aZsShareService.insertAZsShare(aZsShare));
    }

    /**
     * 修改知识共享
     */
    @PreAuthorize("@ss.hasPermi('pm:zsShare:edit')")
    @Log(title = "知识共享", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AZsShare aZsShare)
    {
        return toAjax(aZsShareService.updateAZsShare(aZsShare));
    }

    /**
     * 删除知识共享
     */
    @PreAuthorize("@ss.hasPermi('pm:zsShare:remove')")
    @Log(title = "知识共享", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aZsShareService.deleteAZsShareByIds(ids));
    }
}
